package com.example.jdbc.service;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.example.jdbc.domain.Book;

/**
 * Project:spring-boot-jdbc
 * <p>
 * Title:BookRowMapper.java
 * <p>
 * Description:如果SQL查询出来的数据列名就是和实体类的属性名不一样，或者想按照自己的规则来装配实体类，那么就可以定义并使用自己的Row
 * <p>
 * Copyrigth:Jiang Software LTD.co Copyright (c) 2025
 * <p>
 * 
 * @version 1.0
 * @since 1.8
 * @author jiang
 * @history 2025 jiang create
 */
public class BookRowMapper implements RowMapper<Book> {

	@Override
	public Book mapRow(ResultSet rs, int rowNum) throws SQLException {
		Book book = new Book();
		book.setBookId(rs.getInt("bookId"));
		book.setBookName(rs.getString("bookName"));
		book.setBookAddress(rs.getString("bookAddress"));
		return book;
	}
}